package com.queen.testretrofitrxjava.http;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import com.queen.testretrofitrxjava.applications.ApplicationController;

/**
 * Created by liukun on 16/3/9.
 */
public class NetworkUtil {
    //判断网络是否连接
    public static boolean isNetworkConnected() {
        ConnectivityManager mConnectivityManager = (ConnectivityManager) ApplicationController.getsInstance()
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
        if (mNetworkInfo != null) {
            return mNetworkInfo.isAvailable();
        }
        return false;
    }
}